<div class="setting nomenu">
    <div class="right" style="width:700px;margin-right:70px;padding-left:50px;">
        <div class="modelmodify">
            <div class="info">
                <span class="title">模特姓名:</span>
                <span><?=$model['modelname']?></span>
            </div>
            <div class="info">
                <span class="title">别<span class="title_middle"></span>名:</span>
                <input id="nickname" class="text text_middle" type="text" value="<?=$model['nickname']?>" />
            </div>
            <div class="info">
                <span class="title">国<span class="title_middle"></span>籍:</span>
                <input id="country" class="text text_middle" type="text" value="<?=$model['company']?>" />
            </div>
            <div class="info">
                <span class="title">类<span class="title_middle"></span>型:</span>
                <select id="style" class="select flg text hover">
                	<?php foreach ($modelStyle as $k=>$v){?>
                    <option value="<?=$k?>" <?php if($k == $model['style']){?>selected="selected"<?php }?> ><?=$v?></option>
                    <?php }?>
                </select>
            </div>
            <div class="info">
                <span class="title">身<span class="title_middle"></span>高:</span>
                <input id="height" class="text text_small" type="text" value="<?=$model['height']?>" />
            </div>
            <div class="info">
                <span class="title">胸<span class="title_middle"></span>围:</span>
                <input id="bust" class="text text_small" type="text" value="<?=$model['bust']?>" />
            </div>
            <div class="info">
                <span class="title">腰<span class="title_middle"></span>围:</span>
                <input id="waist" class="text text_small" type="text" value="<?=$model['waist']?>" />
            </div>
            <div class="info">
                <span class="title">臀<span class="title_middle"></span>围:</span>
                <input id="hip" class="text text_small" type="text" value="<?=$model['hip']?>" />
            </div>
            <div class="info">
                <span class="title">鞋<span class="title_middle"></span>围:</span>
                <input id="shoescode" class="text text_small" type="text" value="<?=$model['shoescode']?>" />
            </div>
            <div class="info">
                <span class="title company">母公司:</span>
                <input id="company" class="text text_middle" type="text" value="<?=$model['company']?>" />
            </div>
            <div class="info">
                <span class="title">在京时间:</span>
                <input id="beijingstart" class="time text hover" type="text" value="<?=Model_Common::getFormatTimeYMD($model['beijingstart'])?>" onClick="WdatePicker({readOnly:true,lang:'zh-cn'})" />
                <span class="fromto">至</span>
                <input id="beijingend" class="time text hover" type="text" value="<?=Model_Common::getFormatTimeYMD($model['beijingend'])?>" onClick="WdatePicker({readOnly:true,lang:'zh-cn'})" />
            </div>
            <div class="info">
                <?php if($model['illstart'] != 0 && $model['illend'] != 0){?>
                <span class="title">休假时间:</span>
                <input id="illstart" class="time text hover" type="text" value="<?=Model_Common::getFormatTimeYMD($model['illstart'])?>" onClick="WdatePicker({readOnly:true,lang:'zh-cn'})" />
                <span class="fromto">至</span>
                <input id="illend" class="time text hover" type="text" value="<?=Model_Common::getFormatTimeYMD($model['illend'])?>" onClick="WdatePicker({readOnly:true,lang:'zh-cn'})" />
                <?php }else{?>
                <span class="title">休假时间:</span>
                <input id="illstart" class="time text hover" type="text" value="" onClick="WdatePicker({readOnly:true,lang:'zh-cn'})" />
                <span class="fromto">至</span>
                <input id="illend" class="time text hover" type="text" value="" onClick="WdatePicker({readOnly:true,lang:'zh-cn'})" />
                <?php }?>
            </div>
            <div class="info">
                <span class="title floatleft">休假信息:</span>
                <textarea id="illinfo" class="multtext"><?=$model['illinfo']?></textarea>
            </div>
            <div class="info" id="modelimgwapper">
                <div><span class="title">模特图片列表如下:</span></div>
                <?php foreach($model['media'] as $imgurl){?>
                    <div style="margin-top:10px;"><span></span></div>
                    <div><input value='<?=$imgurl['name']?>' class="modelimg nodisplay"/><span><img style='max-width:550px;' src='<?=$imgurl['url']?>'></span><span style="margin-left:8px;" class='btn' onclick='$(this).parent().remove()'>删除</span></div>
                <?php }?>
            </div>
            <div class="info">
                <span class="title">上传图片:</span>
                <input id="upload" name="upload" type="file" value="" />
                <span id="imgadd" class="btn imgadd">上传</span>
            </div>
            <div class="errmsg" id="errmsg"></div>
            <div class="info">
            	<input class="btn btn_add btn_input return" type="button" onclick="window.location.href='<?=$ref?>'" value="返 回">
                <input id="modeladd" class="btn btn_add btn_input modify" type="button" value="确 认 修 改">
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    $("#modelname").focus();
    $("#modeladd").click(function(){
        $("#errmsg").text("");
        modelimgs = "";
        $('.modelimg').each(function(){
            modelimgs += $(this).attr("value");
            modelimgs += ",";
            
        });
        $.ajax({
              url: "http://<?=HOST?>/model/doModify",
              cache: false,
              timeout:10000,
              type: "POST",
              data: {
                  modelid:<?=$model['modelid']?>,
                  modelname:$("#modelname").val(),
                  nickname:$("#nickname").val(),
                  country:$("#country").val(),
                  height:$("#height").val(),
                  bust:$("#bust").val(),
                  waist:$("#waist").val(),
                  hip:$("#hip").val(),
                  shoescode:$("#shoescode").val(),
                  company:$("#company").val(),
                  beijingstart:$("#beijingstart").val(),
                  beijingend:$("#beijingend").val(),
                  illstart:$("#illstart").val(),
                  illend:$("#illend").val(),
                  illinfo:$("#illinfo").val(),
                  style:$("#style").val(),
                  media:modelimgs
              },
              dataType: "json",
              beforeSend: function() {
                  disableHTML(true, '请稍等，处理中……', true);
              },
              success: function(data) {
                  if(data.errCode != 0){
                      disableHTML(true, data.errMsg, false);
                      setTimeout(disableHTML,2000);
                        $("#errmsg").text(data.errMsg);
                        $("#modelname").focus();
                  }else{
                      disableHTML(true, '修改成功，跳转中……', true);
                      setTimeout("location.href = 'http://<?=HOST?>/model/detail/modelid/<?=$model['modelid']?>'", 500);
                  }
              },
              error:function(){
                      disableHTML(true, "请求出错，请重试或联系系统管理员", false);
                      setTimeout(disableHTML,2000);
                  }
            });
    });
    $("#imgadd").click(function (){
        ajaxFileUpload();
        
    });
    function ajaxFileUpload()
    {
        $("#upload").ajaxStart(function(){
            $("#errmsg").text("");
            disableHTML(true, '请稍等，上传中……', true);
        })
        $.ajaxFileUpload
        (
            {
                url:"http://<?=HOST?>/model/doUpload", 
                secureuri:false,
                fileElementId:'upload',
                dataType: 'json',
                success: function (data, status)
                {
                    if(data.errCode != 0){
                        disableHTML(true, data.errMsg, false);
                        setTimeout(disableHTML,2000);
                        $("#errmsg").text(data.errMsg);
                      }else{
                        disableHTML(true, '上传成功', false);
                        $("#upload").val("");
                        setTimeout(disableHTML,1000);
                        url = '<?=UPLOAD_PATH?>/' + data.name;
                        img = "<div><input class='modelimg' value='" + data.name + "' style='display:none;'/><span><img style='max-width:550px;' src='" + url + "'></span><span style='margin-left:8px;' class='btn' onclick='$(this).parent().remove()'>删除</span></div>"
                        $("#modelimgwapper").append(img);
                      }
                },
                error: function (data, status, e)
                {
                      disableHTML(true, "请求出错，请重试或联系系统管理员", false);
                      setTimeout(disableHTML,2000);
                }
            }
        )
        
        return false;

    }  
</script>
